Preconditions

Simple static methods to be called at the start of your own methods to verify correct arguments and state.

Functions

Link copied to clipboard
open fun checkArgument(expression: Boolean)

open fun checkArgument(expression: Boolean, @NonNull errorMessage: Any)
open fun checkArgument(expression: Boolean, @NonNull messageTemplate: String, @NonNull messageArgs: Array<Any>)
Ensures that an expression checking an argument is true.
Link copied to clipboard
open fun checkArgumentFinite(value: Float, @NonNull valueName: String): Float
Ensures that the argument floating point value is a finite number.
Link copied to clipboard
open fun checkArgumentInRange(value: Double, lower: Double, upper: Double, @NonNull valueName: String): Double
Ensures that the argument double value is within the inclusive range.
open fun checkArgumentInRange(value: Float, lower: Float, upper: Float, @NonNull valueName: String): Float
Ensures that the argument float value is within the inclusive range.
open fun checkArgumentInRange(value: Int, lower: Int, upper: Int, @NonNull valueName: String): Int
Ensures that the argument int value is within the inclusive range.
open fun checkArgumentInRange(value: Long, lower: Long, upper: Long, @NonNull valueName: String): Long
Ensures that the argument long value is within the inclusive range.
Link copied to clipboard
@IntRange(from = 0)
open fun checkArgumentNonnegative(value: Int): Int
@IntRange(from = 0)
open fun checkArgumentNonnegative(value: Int, @Nullable errorMessage: String): Int
Ensures that that the argument numeric value is non-negative.
Link copied to clipboard
open fun checkFlagsArgument(requestedFlags: Int, allowedFlags: Int): Int
Check the requested flags, throwing if any requested flags are outside the allowed set.
Link copied to clipboard
open fun <T> checkNotNull(@Nullable reference: T): T
open fun <T> checkNotNull(@Nullable reference: T, @NonNull errorMessage: Any): T
Ensures that an object reference passed as a parameter to the calling method is not null.
Link copied to clipboard
open fun checkState(expression: Boolean)
open fun checkState(expression: Boolean, @Nullable message: String)
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
Link copied to clipboard
open fun <T : CharSequence?> checkStringNotEmpty(@Nullable string: T, @NonNull errorMessage: Any): T
open fun <T : CharSequence?> checkStringNotEmpty(@Nullable string: T, @NonNull messageTemplate: String, @NonNull messageArgs: Array<Any>): T
Ensures that an string reference passed as a parameter to the calling method is not empty.